<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<%@ include file="/include/header.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${basePageTitle}</title>
<link href="${baseURL}/css/um/register.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
head = document.getElementsByTagName("head")[0];
cssLink = document.createElement("link");
cssLink.rel = cssLink.rev = "stylesheet";
cssLink.type = "text/css";
cssLink.media = "screen";
head.appendChild(cssLink);
if ($.browser.msie) {
	(function() {
		var e = "article,aside,details,figure,footer,header,nav,section"
				.split(','), i = e.length;
		while (i--) {
			document.createElement(e[i]);
		}
	})();
	cssLink.href = "${baseURL}/css/download_ie.css";
} else {
	cssLink.href = "${baseURL}/css/download.css";
}
/**
 * 字母_数字
 * @param {Object} str 待验证的字符串
 * @param {Object} message 提示时的说明
 * @param {Object} minLength 最小长度
 * @param {Object} maxLength 最大长度
 * @return {TypeName} 
 */
function validLetterNumber (str, message, minLength, maxLength){
	 if(str){
		var objectLength = str.length;
		if(objectLength<minLength || objectLength>maxLength){
			var retMsg = message+",长度不正确,应该在"+minLength+"-"+maxLength+"位";
			alert(retMsg);
			return false;
		}
		var letterNumber=/^[A-Za-z0-9]+$/;
		if(letterNumber.test(str)){
			return true;
		}else {
			var retMsg = message+",只能包含字母、数字!";
			alert(retMsg);
			////$.ligerMessageBox.error({title:'警告信息',content:'<div style="padding-top:15px;padding-left:5px"><b>'+retMsg+'</b></div>'});
			return false;
		}
	 }
	 return false;
};
function validLogin(){
	var userNameId = $('#userName').val();
	if(userNameId==""){
		alert('<s:text name="register.inputUserName"/>');
	}
	var userNameIdResult = validLetterNumber(userNameId, '<s:text name ="register.username"/>', 2, 16);
	if(!userNameIdResult){
		return false;
	}
	
	var passWordId = $('#passWord').val();
	if(passWordId==""){
		alert('<s:text name="register.inputPass"/>');
	}
	var passWordIdResult = validLetterNumber(passWordId, '<s:text name="register.password"/>', 6, 16);
	if(!passWordIdResult){
		return false;
	}
	FDCWait.show();
	setTimeout(function(){document.userLoginForm.submit()},500);
}
$(document).ready(function() {
	var errorMsg = '<%=request.getAttribute("errorMessage")%>';
	 if(errorMsg!='null'&&errorMsg!=null){
		 alert(errorMsg);
	}
	//1.初始化页面焦点
	$('#userName').focus();
	//2.键盘事件
	var tds = $("html"); 
	tds.keydown(function(event){
		var myEvent = event || window.event; //解决不同浏览器获取事件对象的差异
			switch(myEvent.keyCode) {
				case 13://回车事件
					validLogin(); break;
			}
	});
    if(window.opener){
        window.opener.close();
        window.opener = null;
    }

   
    
});


/*登录验证*/
function checkdata(){
	var name = document.getElementById('lgName').value;
	var pass = document.getElementById('userPass').value;
	if(name.trim()==""){
		alert("请输入用户名！");
		return;
	}
	if(pass.trim()==""){
		alert("请输入密码！");
		return;
	}
	 
	if(name!=""&&pass!=""){
		var Regx = /^[A-Za-z0-9]*$/;
           if (Regx.test(name)) {
               var formObj = document.getElementById("loginFormId");
               alert("login");
          		$("#login-img").attr("disabled",'true');
				formObj.submit();
           }else{
          	//	alert("用户名只能包含[A-Z],[a-z],[0-9]中的字符");
           	  var formObj = document.getElementById("loginFormId");
           	  	
				formObj.submit();
           }
	}
	
}

String.prototype.trim = function()
{
   return this.replace(/(^\s+)|\s+$/g,"");
};
 
 
 	function keyBorder(event){

			 //alert(event == window.event); 
			if( event.keyCode == 13 ){ // 13表示回车键
				document.getElementById('go').click();					
			}
		}
		
	function openDia(){
		var heightconst=400;
		var widthconst=600;
		var leftconst=(screen.availWidth-widthconst)/2;
		var topconst=(screen.availHeight-heightconst)/2;
		wZoom="dialogLeft:"+leftconst+"px;dialogTop:"+topconst+"px;dialogHeight:"+heightconst+"px;dialogWidth:"+widthconst+"px; center: no; help: no;status:no";
		window.showModalDialog("/pms/kpUser/getPassword.do",window.document,wZoom);
		
	}
	function changeIMG(){
		
 		$("#login-img").attr({src:'<%=request.getContextPath()%>/images/login_btn_press.png'});
		
	}
	function changeOUT(){
 		$("#login-img").attr({src:'<%=request.getContextPath()%>/images/-Login_12.png'});
 	}
	
	function tiyan(){
		var flag=confirm("很抱歉！暂不开放注册功能。\n\n是否进入体验版？");
		if(flag==true){
			var url="<%=request.getContextPath()%>/experience.jsp";
			var w_w = 968 + 10;
			var w_h = 605 + 10;
			var left = (window.screen.availWidth - w_w) / 2;
			var top = (window.screen.availHeight - w_h) / 2;
			var sheight = screen.height;
			var swidth = screen.width;
			window.showModalDialog(url, window, 'dialogHeight=' + w_h
					+ 'px;dialogWidth=' + w_w + 'px;dialogTop=' + top
					+ 'px;dialogLeft=' + left
					+ 'px;status=no;scroll=yes;resizable=yes;center=no');
		}
	}
	
	function login() {
		//先进入后台验证
		/* if(checkUsername()){
			$('#loginFormId').submit();
		} */
		$('#loginFormId').submit();
	}
	//后台验证
	function checkUsername(){
		var userName=$("#j_username").val();
		$.ajax({ 
			type: "post", 
			async: false,//同步
			url: "${baseURL}/system/log/checkUserLogin.action", 
			data :{ userName:userName},
			dataType: "json",
			success: function (result) { 
				if(result && result.hasOk){//成功
					return true;
				}else{
					$(this).attr("disabled", false);
					alert(result.message);
					return false;
				}
			}
		});
	}
	
	function refreshCode(){
		$('#checkCode').attr('src',"../jcaptcha.jpg?"+Math.random());
	}
	
	$(function(){
		$(document).keydown(function(e){
		  if(e.keyCode == 13)
            {
			   $('#loginFormId').submit();
            }
         });
	});
</script>



<style type="text/css">
.tbllogin td.left {
	text-align: left;
	width: 200px;
	text-indent: 160px;
}

.tbllogin td {
	text-align: left;
	padding: 0 5px;
}
</style>


</head>
<body id="aboutus">
	<header>
		<%@ include file="/include/start/start_header2.jsp"%>
	</header>
	<div id="center" style="height: 370px;">
		<div class="register_content" style="height: 370px;">
			<div class="register_content_top"></div>
			<div class="register_content_center" style="height: 400px;">
				<h3 class="second_title">
					<s:i18n name="signin"> 
  							<s:text name="signin.signIn"></s:text>
					</s:i18n></h3>
				<div class="kong5yuan_enterprise" ></div>
			<FORM id=loginFormId method=post action="<%=request.getContextPath()%>/j_spring_security_check">

				<ul style="text-align:center;">
				    <c:if test="${param.login_error == '1'}">
				      <li><font color='red'><s:text name="register.userPassError"></s:text></font></li>
				    </c:if>
				    <c:if test="${param.login_error == '2' }">
				      <li><font color='red'><s:text name="register.verificationCode"></s:text></font></li>
				    </c:if>
					<li>
				</ul>
				<ul>
					<li><s:i18n name="register"> 
  							<s:text name="register.username"></s:text>
					</s:i18n>:&nbsp;&nbsp;&nbsp;<input type="text" name="j_username" id="j_username" /></li>
					<li><s:i18n name="register">
  							<s:text name="register.password"></s:text>
					</s:i18n>:&nbsp;&nbsp;&nbsp;<input type="password" name="j_password" id="j_password" /></li>
				</ul>
				<div class="<s:text name='forms.btnlogin'/>" onclick="javascript:login()">
			</FORM>
			</div>
			<div class="register_content_bottom"></div>
		</div>
	</div>
	<p>&nbsp;</p>
	<br>
	<br>
	<br>
	<br>
	<!-- 页脚 -->
	<footer>
	<%@ include file="/include/start/start_footer.jsp"%>
	</footer>
</body>
</html>